import 'package:base/base.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:bruno/bruno.dart';

class PCConnectionHomeWidget extends StatefulWidget {
  const PCConnectionHomeWidget({super.key});

  @override
  State<StatefulWidget> createState() {
    return _PCConnectionHomeState();
  }
}

class _PCConnectionHomeState extends State<PCConnectionHomeWidget> {
  late FToast fToast;
  GlobalKey? _leftKey;

  Widget toast = Container(
    padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(25.0),
      color: Colors.greenAccent,
    ),
    child: const Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        Icon(Icons.check),
        SizedBox(
          width: 12.0,
        ),
        Text("This is a Custom Toast"),
      ],
    ),
  );

  @override
  void initState() {
    _leftKey = GlobalKey();
    fToast = FToast();
    fToast.init(navigatorKey.currentContext!);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
        decoration: const BoxDecoration(color: Colors.blue),
        alignment: Alignment.center,
        width: 325,
        child: GestureDetector(
          key: _leftKey,
          onTap: () {
            if (kDebugMode) {
              print("onTap");
            }
            // Fluttertoast.showToast(
            //     msg: "This is Center Short Toast",
            //     toastLength: Toast.LENGTH_SHORT,
            //     gravity: ToastGravity.CENTER,
            //     timeInSecForIosWeb: 1,
            //     backgroundColor: Colors.red,
            //     textColor: Colors.white,
            //     fontSize: 16.0
            // );
            // fToast.showToast(child: toast);
            //
            // BrnToast.show(
            //     "BrnToast show success ",
            //     navigatorKey.currentContext!,
            //     duration: const Duration(seconds: 10),
            //     gravity:BrnToastGravity.bottom
            // );
            // showDialog<void>(
            //    context: context,
            //    barrierDismissible: true,
            //    builder: (BuildContext dialogContext) {
            //      return BrnDialog(
            //        messageText: "辅助内容信息辅助内容信息辅助内容信息辅助内容信息辅助内容信息",
            //        actionsText: const ["cancel","ok"],
            //      );
            //    },
            //  );

            // BrnNoticeBarWithButton(
            //   leftTagText: '任务',
            //   content: '这是通知内容',
            //   rightButtonText: '去完成',
            //   onRightButtonTap: () {
            //     BrnToast.show('点击右侧按钮', context);
            //   },
            // );
            BrnPopupWindow.showPopWindow(context, "订阅搜索条件，新上房源立即通知", _leftKey!,
                hasCloseIcon: true,
                dismissCallback: () {},
                popDirection: BrnPopupDirection.bottom);
          },

          // RaisedButton(
          //   key: _leftKey4,
          //   onPressed: () {
          //     BrnPopupWindow.showPopWindow(
          //         context, "订阅搜索条件，新上房源立即通知", _leftKey4,
          //         hasCloseIcon: true,
          //         dismissCallback: () {},
          //         popDirection: PopDirection.bottom);
          //   },
          //   child: Text("右侧带关闭Tips"),
          // )
          child: const Text(
              "PC Connection",
              // textDirection: TextDirection.ltr,
              style: TextStyle(fontSize: 30, color: Colors.white)),
        ));
  }
}
